import 'package:json_annotation/json_annotation.dart';

part 'rsp.g.dart';

@JsonSerializable(genericArgumentFactories: true)
class Rsp<T> {
  final int? errorCode;
  final String? errorMsg;
  final T? data;

  const Rsp({
    this.errorCode,
    this.errorMsg,
    this.data,
  });

  bool get apiSuccess => errorCode == 0;

  factory Rsp.fromJson(Map<String, dynamic> json,T Function(dynamic json) fromJsonT,) =>
      _$RspFromJson(json,fromJsonT);

  Map<String, dynamic> toJson(Object? Function(T value) toJsonT) => _$RspToJson(this, toJsonT);
}
